function [AllDataSampler] = Ddavid_cross_validation_training_testing(AllData, NFold)

% [AllDataSampler] = Ddavid_cross_validation_training_testing(AllData, NFold)
%
% <Input>
% AllData: [n*m], n is the size of dataset, m is the number of features
% NFold: Integer, the number of folds
%
% <Output>
% AllDataSampler: [1*n], the value is {1, 2, ..., NFold} means the data folds

AllDataSize = size(AllData, 1);
FoldSize = AllDataSize / NFold;

AllDataSampler = zeros(1, AllDataSize);
for Index = 1:AllDataSize
    AllDataSampler(Index) = ceil(Index / FoldSize);
end

for Index = AllDataSize:-1:2
    NewIndex = randi(Index);
    Temp = AllDataSampler(NewIndex);
    AllDataSampler(NewIndex) = AllDataSampler(Index);
    AllDataSampler(Index) = Temp;
end
